﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using TLTuan.App.AccessLayer;
using System.Data;

namespace TLTuan.Home
{
    public partial class MyProfile : System.Web.UI.Page
    {
        DataTable table;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                AnButtonSua();
            }
        }        

        private void AnButtonSua()
        {
            table = (DataTable)Session["ThanhVien"];
            if (table!=null && table.Rows.Count > 0)
            {
                if (table.Rows[0]["PK_ThanhvienID"].ToString() == Request.QueryString["user"].ToString())
                    btt_edit.Visible = true;
                else
                    btt_edit.Visible = false;

            }
        }

        protected void btt_edit_Click(object sender, EventArgs e)
        {
            try
            {
                table = (DataTable)Session["ThanhVien"];
                if (table != null && table.Rows.Count > 0)
                {
                    string str_url = "";
                    if (table.Rows[0]["PK_ThanhvienID"].ToString() == Request.QueryString["user"].ToString())
                        str_url = "/Home/SuaThongTinThanhVien.aspx?user=" + table.Rows[0]["PK_ThanhvienID"].ToString();
                    else
                        str_url = "/Home/MyProfile.aspx?user=" + Request.QueryString["user"].ToString();
                    Response.Redirect(str_url);
                }
            }
            catch (Exception ex)
            {
                lab_thongbao.Text = ex.Message;
                lab_thongbao.Visible = true;
            }
        }
    }
}